<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>jstree basic demos</title>
	<style>
	html { margin:0; padding:0; font-size:62.5%; }
	body { margin: 0; font-size:14px; font-size:1.4em; }
	h1 { font-size:1.8em; }
	.demo { overflow:auto; min-height:100px; }
	</style>
	<link rel="stylesheet" href="dist/themes/default/style.min.css" />
</head>
<body>
<div id="event_result"></div>

	<p>tree根部提供url 文件相对地址</p>

	<div id="frmt" class="demo"></div>


	<script src="http://cdn.bootcss.com/jquery/1.12.3/jquery.min.js"></script>
	<script src="dist/jstree.min.js"></script>
    <script src="nav.js"></script>
	
	<script>

        function uiGetParents(loSelectedNode) {
            try {
                var lnLevel = loSelectedNode.node.parents.length;
                var lsSelectedID = loSelectedNode.node.id;
                var loParent = $("#" + lsSelectedID);
                var lsParents =  loSelectedNode.node.text + ',';
                for (var ln = 0; ln <= lnLevel -1 ; ln++) {
                    var loParent = loParent.parent().parent();
                    if (loParent.children()[1] != undefined) {
                        lsParents += loParent.children(".jstree-anchor").text() + ",";
                    }
                }
                if (lsParents.length > 0) {
                    lsParents = lsParents.substring(0, lsParents.length - 1);
                }
                return lsParents.split(",").reverse();
            }
            catch (err) {
                alert('Error in uiGetParents');
            }
        }

	// data format demo
	$('#frmt')
        .on('changed.jstree', function (e, data) {
            var html = 'Selected: ' + uiGetParents(data);
            if (data.node.original.hasOwnProperty("url") && data.node.original != "") {
                html += " 跳转";
			}
            $('#event_result').html(html);
        })
		.jstree(globalnav);

	</script>
</body>
</html>